package com.qt.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
public class UserBean {
    private int id;
    private String username;
    private String password;

    private List<RoleBean> roleBeans;

    public boolean havaAuthority(ResouceBean resouceBean){
        return roleBeans.stream().filter(roleBean -> {
           return roleBean.getResouceBeans()
                   .stream()
                   .filter(resouceBean1 -> resouceBean1.equals(resouceBean)).count()>0;
        }).count()>0;
    }
}
